package com.xy.generate.cli.command.children;

import com.xy.generate.config.MainTemplateConfig;
import com.xy.generate.util.MainGenerator;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import picocli.CommandLine;

import java.util.concurrent.Callable;

/**
 * @author tzf
 * @description: 生成低代码
 * @date: 2024/6/14 15:35
 */
@Slf4j
@CommandLine.Command(name = "generate", description = "生成低代码", mixinStandardHelpOptions = true)
@Data
public class GenerateCommand implements Callable<Integer> {
    @CommandLine.Option(names = {"-l", "--loop"}, arity = "0..1", description = "是否循环生成", interactive = true)
    private boolean loop;
    @CommandLine.Option(names = {"-a", "--author"}, arity = "0..1", description = "作者", interactive = true)
    private String author;
    @CommandLine.Option(names = {"-o", "--output"}, arity = "0..1", description = "输出内容", interactive = true)
    private String outputText;

    @Override
    public Integer call() throws Exception {
        MainTemplateConfig mainTemplateConfig = MainTemplateConfig.builder().author(author).outputText(outputText).loop(loop).build();
        log.info("配置信息=>{}", mainTemplateConfig.toString());
        MainGenerator.doGenerate(mainTemplateConfig);
        return 0;
    }
}
